﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DBModel;
using DBModel.DAL;

namespace CV_Projekt
{
    public partial class FormLogin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void LoginButton_Click(object sender, EventArgs e)
        {
            var user = UserDB.AuthenticateUser(Login1.UserName, Login1.Password);
            
            Session["User"] = user;

            if (user is Applicant)
            {
                Session["CV"] = CurriculumVitaeDB.GetCurriculumVitaeByApplicant(user.UserId);
                Response.Redirect("WorkSearch.aspx");
            }
            if (user is SuperAdmin)
            {
                Response.Redirect("SuperAdmin.aspx");
            }
            if (user is HeadHunter)
            {
                Response.Redirect("HeadHunter.aspx");
            }
            if (user is Publisher)
            {
                Response.Redirect("Publisher.aspx");
            }

        }
    }
}